import request from "@/utils/request";

// 获取客户列表
export function getCustomerList(data, page = 1, pageSize = 10) {
  return request({
    url: `/customer/list?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data,
  });
}

// 新增或修改客户信息
export function addOrEditCustomer(data) {
  return request({
    url: "/customer/saveUpdate",
    method: "post",
    data,
  });
}

// 获取用户详情
export function getCustomerDetail(id) {
  return request({
    url: `/customer/getDetailById?theId=${id}`,
    method: "post",
  });
}

// 获取当前用户关联的店铺
export function getCustomerShopList(params) {
  return request({
    url: `/userShop/userShopList`,
    params,
  });
}

// 获取当前用户未绑定的店铺
export function getCustomerUnBindShopList(userId,type) {
  return request({
    url: `/userShop/noConnectionShopList?userId=${userId}&type${type}&pageNo=1&pageSize=9999`,
  });
}

// 绑定用户到店铺
export function bindShopUser(params) {
  return request({
    url: "/userShop/userAssociateShop",
    params,
  });
}

// 解绑用户
export function unbindShopUser(params) {
  return request({
    url: "/userShop/userCancelAssociateShop",
    params,
  });
}

// 通过电话获取用户详情
export function getCustomerDetailByPhone(phone) {
  return request({
    url: `/customer/getDetailByPhone?getDetailByPhone=${phone}`,
    method: "post",
  });
}

/**
 * 黑明单列表
 */
export function getBlackList(data, page = 1, pageSize = 10) {
  return request({
    url: `/userBlackList/queryUserBlackList?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data,
  });
}

/**
 *
 * 添加或修改黑名单
 */
export function addOrEditBlackList(data) {
  return request({
    url: "/userBlackList/saveUpdateUserBlackList",
    method: "post",
    data,
  });
}

/**
 * 移除黑名单
 */
export function removeBlackList(id) {
  return request({
    url: `/userBlackList/deleteByUserBlackListId?id=${id}`,
  });
}

/**
 * 分销列表
 */
export function getRegionDistributorList(data, page = 1, pageSize = 10) {
  return request({
    url: `/regionDistributor/list?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data,
  });
}

/**
 * 保存
 */
export function saveRegionDistributor(data) {
  return request({
    url: "/regionDistributor/save",
    method: "post",
    data,
  });
}

/**
 * 修改
 *
 */
export function updateRegionDistributor(data) {
  return request({
    url: "/regionDistributor/update",
    method: "post",
    data,
  });
}

/**
 * 修改状态
 */
export function updateRegionDistributorStatus(id, status) {
  return request({
    url: `/regionDistributor/updateStatus?id=${id}&status=${status}`,
  });
}

/**
 * 提现申请列表
 */
export function getWithdrawList(data, page = 1, pageSize = 10) {
  return request({
    url: `/regionTransactionDetail/list?pageNo=${page}&pageSize=${pageSize}`,
    method: "post",
    data,
  });
}

/**
 * 审核提现申请
 */
export function auditWithdraw(data) {
  const { id, status, remark } = data;
  return request({
    url: `/regionTransactionDetail/userWithdrawalRequest?id=${id}&status=${status}&remark=${remark}`,
    method: "post",
  });
}
